﻿//19.Write a program that extracts from a given text all dates that match the format DD.MM.YYYY. Display them in the standard date format for Canada.

using System;
using System.Globalization;
using System.Text.RegularExpressions;

namespace ExtractAllDatesMatches
{
    class ExtractAllDatesMatches
    {
        static void Main()
        {
            string format = "dd.MM.yyyy";

            string text = "bla bla 21.01.2014 ala bala. mrun mrun 31.12.2051"
               + "and more more more 03.03.2012";

            foreach (var extracted in Regex.Matches(text, @"\d{2}.\d{2}.\d{4}"))
            {

                string extractedToString = Convert.ToString(extracted);

                DateTime date = DateTime.ParseExact(extractedToString, format, CultureInfo.InvariantCulture);

                Console.WriteLine(date.ToString(CultureInfo.GetCultureInfo("en-CA")));
            }
        }
    }
}
